package com.hnkywl.sts.service.report;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.hnkywl.sts.dao.report.CwflSfcDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-6-17
 * Time: 下午8:13
 * To change this template use File | Settings | File Templates.
 */
@Service
public class CwflSfcService {
    private CwflSfcDao cwflSfcDao;

    /**
     * 财务库存商品分类收发存报表
     *
     * @param gsid
     * @param year
     * @param month
     * @return
     */
    public String cwflSfcList(Long gsid, Integer year, Integer month) {
        Map<String, List> result = cwflSfcDao.cwflSfcList(gsid, year, month);
        List<Map> rows = result.get("rows");
        List<Map> footer = result.get("footer");
        Gson gson = new GsonBuilder().create();
        String rowsJson = gson.toJson(rows);
        String footerJson = gson.toJson(footer);
        String json = "{\"rows\":" + rowsJson + ",\"footer\":" + footerJson + "}";
        return json;
    }

    /**
     * 库存商品分类月末结转
     *
     * @param year
     * @param month
     * @return
     */
    public String kcspflSfcYmjz(Integer year, Integer month) {
        return cwflSfcDao.kcspflSfcYmjz(year, month);
    }


    @Autowired
    public void setCwKcspflSfcDao(CwflSfcDao cwflSfcDao) {
        this.cwflSfcDao = cwflSfcDao;
    }
}
